<template>
	<view class="container">
		<u--form ref="queryForm" :model="query" label-width="120rpx">
		  <u-form-item label="料架码">
		    <u--input 
		    	placeholder="请输入/扫描" 
		    	v-model.trim="query.rackCode" 
		    	suffixIcon="scan" 
		    	suffixIconStyle="font-size: 68rpx"
		    	style="flex: 1;"
		    >
		    </u--input>
		  </u-form-item>
		</u--form>
		<u-toast ref="uToast"></u-toast>
		<view class="commonButton">
			<u-button type="primary" @click="bindRackCode">绑定</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				query: {
					rackCode: ''
				}
			};
		},
		methods: {
			async bindRackCode() {
				const submitForm = {
					rackCode: this.query.rackCode
				}
				const res = await bindRackCodeAPI(submitForm)
				if (res.code === 200) {
					this.query.rackCode = ''
					this.$refs.uToast.show({
						type: 'success',
						message: res.message
					})
				} else {
					return this.$refs.uToast.show({
						type: 'warning',
						message: res.message
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.commonButton {
		width: 100%;
		display: flex;
		gap: 20rpx;
		position: fixed;
		left: 0;
		bottom: 0;
		box-sizing: border-box;
		padding: 15rpx;
		justify-content: space-between;
		background-color: #fff;
	}
</style>
